package com.atguigu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.base.BaseDAO;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.dao.CommunityDAO;
import com.atguigu.entity.Community;
import com.atguigu.service.CommunityService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @PACKAGE_NAME: com.atguigu.service.impl
 * @CLASSNAME: CommunityServiceImpl
 * @AUTHOR: zhangsan
 * @DATE: 2024/4/21 11:56
 * @SINCE 17.0.7
 * @DESCRIPTION: CommunityServiceImpl
 */
@Service(interfaceClass = CommunityService.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class CommunityServiceImpl extends BaseServiceImpl<Community> implements CommunityService {

    @Resource
    private CommunityDAO communityDAO;

    @Override
    protected BaseDAO<Community> getEntityDAO() {
        return communityDAO;
    }

    /**
     * 查询所有小区
     *
     * @return
     */
    @Override
    public List<Community> findAll() {
        List<Community> communityList = communityDAO.findAll();
        return communityList;
    }

    /**
     * 通过小区id查询小区,并将查询出对应字典表字段的名字
     *
     * @param communityId
     * @return
     */
    @Override
    public Community getDictNameById(Long communityId) {
        Community community = communityDAO.getDictNameById(communityId);
        return community;
    }
}
